home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Communications / Divers / DinkClass ƒ / DinkClass / DinkUtils.c < prev    next >
Encoding:
Text File  |  1992-12-31  |  2.7 KB  |  152 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        DinkUtils.cp
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Mark Gross
  7.  
  8.     Copyright:    © 1992 by Applied Technical Software, all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <4>    12/31/92    MTG        fixing minor typeo
  13.          <3>    12/31/92    MTG        making the code conditionaly compiled so         that I am
  14.                                     always working with a current         version in either think c
  15.                                     or MPW C++
  16.          <2>     9/20/92    MTG        Bringing the C++ verion of DinkClass up to date with the THINKC
  17.                                     version
  18.  
  19.     To Do:
  20. */
  21.  
  22. // this file has a number of utility fuctions
  23. // for The DinkClass
  24. #include <DinkUtils.h>
  25. #include "DApplication.h"
  26. #include "DEventHandler.h"
  27. #include "DDocument.h"
  28. #include <Editions.h>
  29. #include <Traps.h>
  30. #include <GestaltEqu.h>
  31. #ifdef THINK_C
  32.     //NOTHING!, this trap is in the THINK headder files
  33. #else
  34.     //for MPW
  35.     #define _GestaltDispatch 0xA0AD
  36. #endif
  37.  
  38. // commented out for MPW extern DApplication *DEventHandler::gApplication;
  39.  
  40. void InitToolBox(int numMoreMasers)
  41. {
  42.     int i;
  43.     EventRecord event;
  44.     
  45.     MaxApplZone();
  46.     for (i=0; i<numMoreMasers; i++)
  47.         MoreMasters();
  48.  
  49.     FlushEvents(everyEvent, 0);
  50.  
  51.     InitGraf((Ptr) &qd.thePort);
  52. //    InitGraf(&thePort);
  53.     InitFonts();
  54.     InitWindows();
  55.     InitMenus();
  56.     TEInit();
  57.     InitDialogs( NULL);
  58.     InitCursor();
  59.     
  60.     InitEditionPack();
  61.     
  62.     for (i = 1; i <= 3; i++)
  63.         EventAvail(everyEvent, &event);
  64. }
  65.  
  66.  
  67.  
  68.  
  69. OSErr RequiredCheck( AppleEvent *theAppleEvent)
  70. {
  71.     OSErr myErr;
  72.     DescType typeCode;
  73.     Size actualSize;
  74.     
  75.     myErr = AEGetAttributePtr( theAppleEvent, keyMissedKeywordAttr, typeWildCard,
  76.                                 &typeCode, 0L, 0, &actualSize);
  77.     
  78.     if (myErr == errAEDescNotFound ) 
  79.         return noErr;
  80.     
  81.     if (myErr == noErr )
  82.         return errAEEventNotHandled ;
  83.     
  84.     return myErr;
  85. }
  86.  
  87. Boolean System7Available(void)
  88. {
  89.     long sysVersion;
  90.     
  91.     if( !TrapExists(_GestaltDispatch) ) 
  92.         return false;
  93.     
  94.     if( !Gestalt( gestaltSystemVersion, &sysVersion) )
  95.     {
  96.         if(sysVersion >= 0x0700) 
  97.             return true;
  98.     }
  99.     return false;
  100. }
  101.  
  102.  
  103. Boolean TrapExists(short theTrap)
  104. {
  105.     TrapType    theTrapType;
  106.  
  107.     theTrapType = GetTrapType(theTrap);
  108.     if ((theTrapType == ToolTrap) && ((theTrap &= 0x07FF) >= NumToolboxTraps()))
  109.         theTrap = _Unimplemented;
  110.  
  111.     return (NGetTrapAddress(_Unimplemented, ToolTrap) != NGetTrapAddress(theTrap,
  112.                   theTrapType));
  113. }
  114.  
  115. TrapType    GetTrapType(short theTrap)
  116. {
  117.     /* OS traps start with A0, Tool with A8 or AA. */
  118.     if ((theTrap & 0x0800) == 0)                    /* per D.A. */
  119.         return (OSTrap);
  120.     else
  121.         return (ToolTrap);
  122. }
  123.  
  124.  
  125.  
  126. short    NumToolboxTraps(void)
  127. {
  128.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E, ToolTrap))
  129.         return (0x200);
  130.     else
  131.         return (0x400);
  132. }
  133.  
  134.  
  135.  
  136.  
  137. void    pstrcat(Str255 dest, Str255 src)
  138. {
  139.     short    i;
  140.  
  141.     for (i = 0; i < src[0];)
  142.         dest[++dest[0]] = src[++i];
  143. }
  144.  
  145.  
  146. void    pstrcpy(Str255 dest, Str255 src)
  147. {
  148.     BlockMove (src, dest, (*(char *)(src))+1);
  149. }
  150.  
  151.  
  152.